#pragma once
#include <string>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;
namespace Util {
	static string getCurrentTime() {
		time_t t = time(0);
		struct tm* lt = localtime(&t);

		stringstream ss;
		if(lt->tm_hour < 10) {
			ss << '0';
		} 
		ss << lt->tm_hour;
		ss << ':';
		if(lt->tm_min < 10) {
			ss << '0';
		} 
		ss << lt->tm_min;
		ss << ':';
		if(lt->tm_sec < 10) {
			ss << '0';
		} 
		ss << lt->tm_sec;
		return ss.str();
	}

	static string getCurrentDate() {
		time_t t = time(0);
		struct tm* lt = localtime(&t);

		stringstream ss;
		if(lt->tm_mday < 10) {
			ss << '0';
		} 
		ss << lt->tm_mday;
		ss << '-';
		if(lt->tm_mon < 10) {
			ss << '0';
		} 
		ss << (lt->tm_mon + 1);
		ss << '-';
		ss << (lt->tm_year + 1900);
		return ss.str();
	}

	static string getTimeStamp(bool full) {
		if(full) {
			return getCurrentDate() + " " + getCurrentTime();
		}
		return getCurrentTime();
	}

	static void printToFile(string fileName, string text) {
		ofstream myfile;
		myfile.open (fileName, ios::app);	
		myfile << text + "\n";
		myfile.close();
	}
};